package com.qiang.work.test02;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class Demo {
    public static void main(String[] args) throws IOException, ClassNotFoundException, IllegalAccessException, InstantiationException {
        Properties pp = new Properties();
        /*FileReader fr = new FileReader("day18\\conf.properties");
        pp.load(fr);
        fr.close();
        String id = pp.getProperty("stuId");
        String name = pp.getProperty("stuName");
        String age = pp.getProperty("stuAge");
        String sex = pp.getProperty("stuSex");
        Student student = new Student(id, name, Integer.parseInt(age), sex);
        System.out.println(student);*/

        //获取加载器
        /*ClassLoader sc = ClassLoader.getSystemClassLoader();
        InputStream resourceAsStream = sc.getResourceAsStream("conf.properties");*/
        //获取输入流
        InputStream sra = ClassLoader.getSystemResourceAsStream("conf.properties");
        //int read = sra.read();
        System.out.println(sra);
        //System.out.println(pp.getProperty("name"));
        pp.load(sra);
        sra.close();
        Class clazz = Class.forName("com.qiang.work.test02.Student");
        //创建学生对象
        Student student = (Student) clazz.newInstance();
        student.setId(pp.getProperty("stuId"));
        System.out.println(student);


    }
}
